package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateLike;
import com.nbsaas.boot.evaluate.api.domain.response.EvaluateLikeResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* 评价点赞-实体对象转化成响应对象
*/

public class EvaluateLikeResponseConvert  implements Converter<EvaluateLikeResponse,EvaluateLike> {

    @Override
    public EvaluateLikeResponse convert(EvaluateLike source) {
        EvaluateLikeResponse  result = new  EvaluateLikeResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getLikeType()!=null){
                    Map<Integer,String> LikeTypeMap=new HashMap<>();
                        LikeTypeMap.put(1,"有用");
                        LikeTypeMap.put(2,"无用");
                        LikeTypeMap.put(3,"点赞");
                        LikeTypeMap.put(4,"踩");
                    String label=  LikeTypeMap.get(source.getLikeType());
                    result.setLikeTypeName(label);
                    }
                    result.setLikeType(source.getLikeType());
                    if(source.getStoreState()!=null){
                        result.setStoreStateName(String.valueOf(source.getStoreState()));
                    }

                    try {
                        if(source.getUser()!=null){
                            result.setUserName(source.getUser().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getEvaluate()!=null){
                        result.setEvaluate(source.getEvaluate().getId());
                    }
                    if(source.getUser()!=null){
                        result.setUser(source.getUser().getId());
                    }
        return result;
    }

}

